import { createRouter, createWebHistory } from 'vue-router'
import Login from '@/views/Login.vue'
import NotFound from '@/views/NotFound.vue'
import UserList from '@/views/user/List.vue'
import ProFile from '@/views/user/ProFile.vue'
import Main2 from '@/views/Main2.vue'
import CalendarLogV2 from '@/views/user/CalendarLogV2.vue'
import fileUpload from '@/views/user/fileUpload.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    //重定向到登录页
    {
      path: '/',
      redirect: '/login'
    },

    //登录页
    {
      path: '/login',
      name:'login',
      component: Login
    },

    //主页2
    {
      path: '/main2/:username',
      props:true,
      name:'main2',
      component: Main2,
      //嵌套路由
      children:[
        {
          path:'/user/list',
          component:UserList
        },
        {
          path:'/user/profile/:id/:name',
          name:'profile',
          component:ProFile,
          props:true
        },
        {
          path:'/user/calendar',
          component: CalendarLogV2
        },
        {
          path:'/user/fileUpload',
          component: fileUpload
        }
      ]
    },

    //404页面
    {
      path: '/:pathMatch(.*)*',
      component: NotFound
    },

    //404页面
    {
      path: '/:pathMatch(.*)',
      component: NotFound
    }
  ]
})

export default router
